package com.example.cobascene;

import org.andengine.engine.camera.Camera;
import org.andengine.engine.handler.IUpdateHandler;
import org.andengine.engine.options.EngineOptions;
import org.andengine.engine.options.ScreenOrientation;
import org.andengine.engine.options.resolutionpolicy.RatioResolutionPolicy;
import org.andengine.entity.scene.Scene;
import org.andengine.entity.util.FPSLogger;
import org.andengine.ui.activity.BaseGameActivity;
import org.andengine.ui.activity.SimpleBaseGameActivity;

import android.view.KeyEvent;

import com.example.cobascene.config.Game_Data;
import com.example.cobascene.config.Game_Define;

public class MainActivity extends SimpleBaseGameActivity implements Game_Data, Game_Define, IUpdateHandler
{
	public static BaseGameActivity	activity;

	public static final int			SCENE_LOGO		= 1;
	public static final int			SCENE_MENU		= 2;
	public static final int			SCENE_GAMEPLAY	= 3;

	private Camera					camera;
	private SceneManager			sceneManager;

	@Override
	public EngineOptions onCreateEngineOptions()
	{
		// TODO Auto-generated method stub
		activity = this;
		camera = new Camera(0, 0, RES_WIDTH, RES_HEIGHT);
		return new EngineOptions(true, ScreenOrientation.LANDSCAPE_FIXED, new RatioResolutionPolicy(RES_WIDTH,
				RES_HEIGHT), camera);
	}

	@Override
	protected void onCreateResources()
	{
		// TODO Auto-generated method stub
		mEngine.registerUpdateHandler(new FPSLogger());
		mEngine.registerUpdateHandler(this);

	}

	@Override
	protected Scene onCreateScene()
	{
		// TODO Auto-generated method stub
		sceneManager = new SceneManager(activity);
		sceneManager.setScene(SceneManager.SCENE_LOGO);
		return sceneManager.loadedScene;
	}

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event)
	{
		// TODO Auto-generated method stub
		if (keyCode == KeyEvent.KEYCODE_BACK)
		{
			switch (SceneManager.currentScene)
			{
				case SCENE_LOGO:

					break;

				case SCENE_MENU:
					finish();
					break;

				case SCENE_GAMEPLAY:
					sceneManager.setScene(SCENE_MENU);
					break;
			}

		}
		return false;
	}

	@Override
	public void onUpdate(float pSecondsElapsed)
	{
		// TODO Auto-generated method stub

	}

	@Override
	public void reset()
	{
		// TODO Auto-generated method stub

	}

}
